<?php
class Feed extends Controller 
{

    function Feed()
    {
        parent::Controller();
        $this->load->helper('xml');
    }
    
    function rss()
    {
        $data['encoding'] = 'utf-8';
        $data['feed_name'] = 'DerekAllard.com';
        $data['feed_url'] = 'http://localhost/blog';
        $data['page_description'] = 'Code Igniter, PHP, and the World of Web Design';
        $data['page_language'] = 'en-ca';
        $data['creator_email'] = 'Derek Allard is at derek at derekallard dot com';
		$data['head']='<?xml version="1.0" encoding="ISO-8859-1"?>';
        $data['posts'] = $this->Main_model->get_recent_posts(10);    
        header("Content-Type: application/rss+xml");
        $this->load->view('feed/feed_rss2', $data);
		

    }
	
	function atom()
    {
        $data['encoding'] = 'utf-8';
        $data['feed_name'] = 'DerekAllard.com';
        $data['feed_url'] = 'http://localhost/blog';
        $data['page_description'] = 'Code Igniter, PHP, and the World of Web Design';
        $data['page_language'] = 'en-ca';
        $data['creator_email'] = 'Derek Allard is at derek at derekallard dot com';
		$data['head']='<?xml version="1.0" encoding="ISO-8859-1"?>';
        $data['posts'] = $this->Main_model->get_recent_posts(10);    
        //header("Content-Type: application/rss+xml");
        $string=$this->load->view('feed/feed_atom', $data,TRUE);
		//$string=ob_get_contents();// get the output code
		ob_get_clean();
		$string = str_replace("\n", '', $string);// remove \n
		$string = str_replace("\r", '', $string);// remove \r
		$string = str_replace("<p>", '', $string);// remove <p>
		$string = str_replace("</p>", '', $string);// remove </p>
		echo($string);// get the clean code 

    }
}
